// 菜单管理
import request from "@/utils/request";
// 引入ts类型
import type { MenuParams, PermissionResponseData } from '@/api/acl/menu/type'
// 枚举
enum API {
    // 获取全部菜单与按钮的标识数据
    ALLPERMISSTION_URL = '/admin/acl/permission',
    // 给某一级菜单新增子菜单
    ADDPERMISSION_URL = '/admin/acl/permission/save',
    // 修改某一个已有的菜单
    UPDATEPERMISSION_URL = '/admin/acl/permission/update',
    // 删除已有的菜单
    DELETEMENU_URL = '/admin/acl/permission/remove/'
}

// 获取全部菜单与按钮的标识数据的接口
export const reqAllPermission = () => request.get<any, PermissionResponseData>(API.ALLPERMISSTION_URL)

// 新增|修改 菜单(有id为修改，没有id为新增)
export const AddOrUpdatePermission = (permission: MenuParams) => {
    if (permission.id) {
        return request.put<any, any>(API.UPDATEPERMISSION_URL, permission)
    } else {
        return request.post<any, any>(API.ADDPERMISSION_URL, permission)
    }
}

// 删除已有的菜单
export const reqDeleteMenu = (id: number) => request.delete<any, any>(API.DELETEMENU_URL + id)